﻿using System;
using Glue;
using Xunit;

namespace GlueTests.MappingTests
{
    public class When_adding_a_nested_readonly_relation
    {
        public class DomainPerson { public DomainAddress Address { get; private set; } }
        public class DomainAddress { public String City { get; set; } }

        public class GuiPerson { public GuiAddress Address { get; private set; } }
        public class GuiAddress { public String City { get; set; } }        
        
        private readonly Mapping<DomainPerson, GuiPerson> personMapping;

        public When_adding_a_nested_readonly_relation()
        {
            personMapping = new Mapping<DomainPerson, GuiPerson>();
        }

        [Fact]
        public void Should_succeed()
        {
            personMapping.Relate(domain => domain.Address, gui => gui.Address, new Mapping<DomainAddress,GuiAddress>());
        }

        [Fact]
        public void Should_succeed_with_TowardsRight_relation()
        {
            personMapping.RelateTowardsRight(domain => domain.Address, gui => gui.Address, new Mapping<DomainAddress, GuiAddress>());
        }

        [Fact]
        public void Should_succeed_with_TowardsLeft_relation()
        {
            personMapping.RelateTowardsLeft(domain => domain.Address, gui => gui.Address, new Mapping<DomainAddress, GuiAddress>());
        }
    }
}
